class Solution {
    public:
        int minSubArrayLen(int target, vector<int>& nums) {
            int i=0;
            int sum=0;
            int minn=__INT_MAX__;
            int length=0;
            for(int j=0;j<nums.size();j++){
                sum+=nums[j];
                while(sum>=target){
                    length=j-i+1;
                    minn=min(length,minn);
                    sum-=nums[i++];
                }
            }
            return minn==__INT_MAX__?0:minn;
        }
    };